/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pb138.srgsxmldb.servlets;

import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;

/**
 * custom error listener class using by xsl transformation
 *
 * @author Eldred
 */
public class MyErrorListener implements ErrorListener {

  @Override
  public void warning(TransformerException e)
  throws TransformerException {
      
    show("Warning",e);
    throw(e);
  }
  
  @Override
  public void error(TransformerException e)
  throws TransformerException {
      
    show("Error",e);
    throw(e);
  }
  
  @Override
  public void fatalError(TransformerException e)
  throws TransformerException {
      
    show("Fatal Error",e);
    throw(e);
  }
  
  private void show(String type,TransformerException e) {
      
    System.out.println(type + ": " + e.getMessage());
    if(e.getLocationAsString() != null)
    System.out.println(e.getLocationAsString());
  }
    
}
